#include <bits/stdc++.h>

using namespace std;

int n,a,b,d[300];
bool hasvis[300];
int main()
{
    cin >> n >> a >> b;
    queue <int> q;
    queue <int> s;
    for(int i =1;i<=n;i++){
        cin>>d[i];
    }
    q.push(a);
    s.push(0);
    hasvis[a] = 1;
    while(!q.empty()){
        int tf = q.front();
        int ts = s.front();
        if(tf==b){
            cout<<ts;
            return 0;
        }
        int tn = tf+d[tf];
        if(tn<=n&&!hasvis[tn]){
            q.push(tn);
            s.push(ts+1);
            hasvis[tn] = 1;
        }
        tn = tf - d[tf];
        if(tn>=1&&!hasvis[tn]){
            q.push(tn);
            s.push(ts+1);
            hasvis[tn] = 1;
        }
        q.pop();
        s.pop();
    }
    cout<<-1;
    return 0;
}
